home *** CD-ROM | disk | FTP | other *** search
/ Bride Wars Press Kit / Bride Wars DPK.iso / pc / resources / functions / download.exe / download.dxr / 00005_Download Files.ls < prev    next >
Encoding:
Text File  |  2007-02-26  |  2.8 KB  |  102 lines

  1. global gbPC, gFilePath, gPicNo, pcxObj, gSavedList, gFirstSave, captions, downloadPath
  2.  
  3. on downloadFiles DLType
  4.   dtPath = baSysFolder("desktop")
  5.   if dtPath = EMPTY then
  6.     alert("Error finding desktop folder")
  7.     go("exit")
  8.   end if
  9.   destRoot = dtPath & member("target").text.line[1]
  10.   if gbPC then
  11.     destRoot = destRoot & "\"
  12.   else
  13.     destRoot = destRoot & ":"
  14.   end if
  15.   if not baFolderExists(destRoot) then
  16.     put "create folder"
  17.     res = baCreateFolder(destRoot)
  18.     if res = 0 then
  19.       alert("Error creating folder on desktop")
  20.       go("exit")
  21.     end if
  22.   end if
  23.   repeat with itemName in gSavedList
  24.     SrcPath = downloadPath & itemName
  25.     destPath = destRoot & itemName
  26.     if baFolderExists(SrcPath) then
  27.       saveFolder(SrcPath, destPath)
  28.       next repeat
  29.     end if
  30.     if baFileExists(SrcPath) then
  31.       saveFile(SrcPath, destPath)
  32.       next repeat
  33.     end if
  34.     alert("Error saving file " & SrcPath)
  35.     exit
  36.     go("exit")
  37.   end repeat
  38.   if gFirstSave = 1 then
  39.     Ok = baActivateWindow(baWinHandle())
  40.     if not (captions = VOID) then
  41.       captionSave()
  42.     end if
  43.     alertObj = new(xtra("MUI"))
  44.     alertInitList = [#buttons: #Ok, #default: 1, #title: "Files Saved", #message: "Files have been downloaded to your Desktop.", #movable: 1]
  45.     gSavedList = []
  46.     if objectp(alertObj) then
  47.       result = alert(alertObj, alertInitList)
  48.     end if
  49.     gFirstSave = 1
  50.   end if
  51.   if gFirstSave = 0 then
  52.     Ok = baActivateWindow(baWinHandle())
  53.     if not (captions = VOID) then
  54.       captionSave()
  55.     end if
  56.     alertObj = new(xtra("MUI"))
  57.     alertInitList = [#buttons: #Ok, #default: 1, #title: "Files Saved", #message: "Files have been downloaded to your Desktop.", #movable: 1]
  58.     gSavedList = []
  59.     if objectp(alertObj) then
  60.       result = alert(alertObj, alertInitList)
  61.     end if
  62.     gFirstSave = 1
  63.   end if
  64.   if gFirstSave = -1 then
  65.     Ok = baActivateWindow(baWinHandle())
  66.     alertObj = new(xtra("MUI"))
  67.     alertInitList = [#buttons: #Ok, #default: 1, #title: "Files Saved", #message: "These files have already been downloaded.", #movable: 1]
  68.     gSavedList = []
  69.     if objectp(alertObj) then
  70.       result = alert(alertObj, alertInitList)
  71.     end if
  72.     gFirstSave = 1
  73.   end if
  74.   quitProgram()
  75. end
  76.  
  77. on saveFile src, dest
  78.   Ok = baActivateWindow(baWinHandle())
  79.   downloadcheck = 0
  80.   filecheck = baFileExists(dest)
  81.   if filecheck = 0 then
  82.     downloadcheck = 1
  83.     gFirstSave = 1
  84.     res = baCopyFileProgress(src, dest, "IfNotExist", "Saving Files...", "Cancel", 0)
  85.   end if
  86.   if downloadcheck = 0 then
  87.     gFirstSave = -1
  88.   end if
  89. end
  90.  
  91. on saveFolder src, dest
  92.   Ok = baActivateWindow(baWinHandle())
  93.   if not baFolderExists(dest) then
  94.     res = baCreateFolder(dest)
  95.     if res = 0 then
  96.       alert("Error creating folder.")
  97.       go("exit")
  98.     end if
  99.   end if
  100.   res = baXCopyProgress(src, dest, "*.*", "IfNotExist", 1, "Saving Files..." & src, "Cancel", 0)
  101. end
  102.